function oBlur_1() {
    let a = document.getElementById("patternName").value;
    if (a == "") {
        document.getElementById("remind_1").innerHTML = "模式名字不能为空！".fontcolor("red");
        document.getElementById("change_margin_1").style.marginBottom = 1 + "px";
    } else {
        document.getElementById("remind_1").innerHTML = "";
        document.getElementById("change_margin_1").style.marginBottom = 19 + "px";
    }
}

function oFocus_1() {
    document.getElementById("remind_1").innerHTML = "";
    document.getElementById("change_margin_1").style.marginBottom = 19 + "px";
}

window.onload = function(){

    var index = parent.layer.getFrameIndex(window.name);

    $('#savePattern').click(function () {
        /*if(!submitTest())
            parent.layer.confirm('信息未全，不能添加！',{btn:['确定']});
        else {*/
        var patternName = $("#patternName").val();
        var patternSoftware = $("#patternSoftware").val().join(',');

        if(patternName==""){
            parent.layer.confirm('关键信息未全，不能添加！',{btn:['确定']});
        }else {
            $.ajax({
                url: constUrl + "MonitorPatternServlet",
                type: 'post',
                data: {
                    operateType: "add",
                    patternName: patternName,
                    patternSoftware: patternSoftware,
                },
                dataType: 'json',
                success: function (dataText) {
                    console.log(dataText.result);
                    if (dataText.result) {
                        parent.layer.confirm('添加成功！', {
                            btn: ['确定']
                        }, function () {
                            parent.location.reload(index);
                            parent.layer.close(index);
                        })
                    }else {
                        parent.layer.confirm('创建失败！', {
                            btn: ['确定']
                        }, function () {
                            parent.layer.close(index);
                        })
                    }
                },

                complete: function () {
                },
                error: function () {

                }
            });
        }
    });

    $('#closeIframe').click(function(){
        parent.layer.close(index);
    });

    $.ajax({
        url:constUrl+"MonitorSoftwareServlet",
        type:'post',
        data:{
            operateType:"showAll"
        },
        dataType:'json',
        success: function(responseText) {
            var softwareHtml ='';
            for(var i=0;i<responseText.datas.length;i++){
                softwareHtml+='<option value="'+(responseText.datas[i].softwareId)+'" >'+responseText.datas[i].softwareName+'</option>'
            }
            $("#patternSoftware").append(softwareHtml);
        },
        complete: function() {
        },
        error: function() {
        }
    });
}

